|
|
|
|
|
|
|
Tutorial 1
Finding Functions |
|
|
|
|
|
|
|
|
If you were to compare the complexity of the Win32 API and the world's financial systems with regard to international trade, you would almost certainly find that the world's financial system is more complex. |
|
|
|
|
|
|
|
|
If you were to compare the process of world trade with the way Windows manages functions, you might find that they work almost identically.1 |
|
|
|
|
|
|
|
|
Think instead, about how countries exchange goods. |
|
|
|
|
|
|
|
|
A U.S. exporter might have a large supply of jumbo jet airplanes to sell. A Chinese importer might have a sudden need for these jets. A few trans-Pacific faxes later, the deal is done. |
|
|
|
|
|
|
|
|
Later that day, a U.S. importer might see a great market for fried chocolate bars. He might contact his Chinese friend to see if they have any available. His friend responds that no, they aren't exporting chocolate today. The U.S. importer immediately sends e-mail to exporters around the world to see who can provide the product. If he doesn't find anyone, thousands of potential customers may have to do without their chocolate, and the importer may eventually go out of business. |
|
|
|
|
|
|
|
|
A trade can occur only if the product an exporter has available exactly matches the product an importer wants to purchase. |
|
|
|
|
|
|
|
|
When it comes to accessing functions in dynamic link libraries, things work exactly the same way. A DLL may make internal functions available to outside programs and other DLLs by exporting them. It does this by listing them in an internal export list that Windows knows how to examine. A Visual Basic program specifies that it wants to import a file by referencing it in a Declare statement or referencing a type library. The Declare statement contains two pieces of information to specify the function to import: the name of the DLL file and the name of the function. The function name is specified in the ''alias" field of the Declare statement. If no "alias" field is present, VB assumes that the function name you specify in the statement is identical to the function name in the DLL. |
|
|
|
|
|
|
|
|
Declare Sub myfunc Lib "mydll.dll" Alias "otherfunc" () |
|
|
|
 |
|
 |
|
|
1 No, I'm not referring to the fact that Microsoft finds both equally profitable. |
|
|
|
|
|